#!/usr/bin/env python

from amgineirc.viewModel.viewModel import ViewModel

class AppViewModel(ViewModel):
    def __init__(self, view, appdata):
        ViewModel.__init__(self, view)
        self._appdata = appdata
        # know when connected or not for buttons
        appdata['client'].register_on_connect(self.set_status_bar)
        appdata['client'].register_on_disconnect(self.set_status_bar)

    def set_status_bar(self):
        self.view.set_status_bar(self._appdata['client'].is_connected)
